package org.jetlinks.pro.koudai.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue;
import org.hswebframework.web.api.crud.entity.GenericEntity;
import org.hswebframework.web.crud.generator.Generators;
import org.hswebframework.web.validator.CreateGroup;

import javax.persistence.Column;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import java.util.Date;

/**
 * 实验项目信息
 *
 * @author zhoukun
 * @since 1.3
 */
@Getter
@Setter
@Table(name = "k_taked_question", indexes = {
    @Index(name = "idx_taked_question_id", columnList = "id")
})
public class TakedQuestionEntity extends GenericEntity<String> {
    @Column(length = 64, nullable = false)
    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
    @Schema(description = "实验项目Id")
    private String takedExperimentId;

    @Column(length = 64, nullable = false)
    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
    @Schema(description = "试题id")
    private String questionId;

    @Column(length = 64)
    @Schema(description = "试题分数")
    private String score;

    @Column(length = 64)
    @Schema(description = "答题答案")
    private String questionResult;

    @Column(updatable = false)
    @DefaultValue(generator = Generators.CURRENT_TIME)
    private Date createTime;

    @Column
    @DefaultValue(generator = Generators.CURRENT_TIME)
    private Date updateTime;

    public TakedQuestionEntity(@NotBlank(message = "[key]不能为空", groups = CreateGroup.class) String takedExperimentId, @NotBlank(message = "[key]不能为空", groups = CreateGroup.class) String questionId) {
        this.takedExperimentId = takedExperimentId;
        this.questionId = questionId;
    }
}
